Registering a New Aptitude Source
Epiphany provides 16 built-in aptitude sources. Third-party mods can extend them with custom event listeners that call AptitudeSourceManager.grant(...).
See Aptitude & Insight Point for datapack fields, and AptitudeSourceManager and AptitudeSourceResolver for Java methods.
Overview
Adding an aptitude behavior requires no additional type registration. You need:
- Datapack JSON: define the default reward, special targets, and exclusion list
- Event listener: listen for the relevant game behavior in your own mod
- API call: call
AptitudeSourceManager.grant(sp, behaviorId, targetId, registry)when the behavior occurs
epiphany:aptitude is a datapack registry. A behavior ID is determined by the JSON file's namespace and relative path. The listener uses the same ID to look up its configuration.
Step 1: Define the Datapack JSON
Create a configuration file at data/<your-modid>/epiphany/aptitude/<behavior>.json.
For example, define mymod:fishing for player fishing:
// data/mymod/epiphany/aptitude/fishing.json
{
"default": [1, 3],
"specials": [
{ "target": "minecraft:cod", "reward": [3, 7], "first_reward": 30 },
{ "target": "minecraft:tropical_fish", "reward": [6, 10], "first_reward": [40, 60] },
{ "target": "minecraft:pufferfish", "reward": 6, "first_reward": 40 }
],
"exclude": []
}default, reward, and first_reward accept a fixed integer, [min, max], or { "min": ..., "max": ... }, with both endpoints included. In this example, the first cod catch grants 33–37 aptitude, and subsequent catches grant 3–7 (with a player multiplier of 1.0).
The behavior ID is mymod:fishing. Moving the file to aptitude/exploration/fishing.json changes the ID to mymod:exploration/fishing.
The meaning of target depends on what the listener passes in. This example uses the caught item's ID, so it can match items such as minecraft:cod or item tags.
Step 2: Write the Listener
The following listener uses NeoForge's ItemFishedEvent. One catch may contain multiple drops; this example grants once per distinct item type, rather than multiplying by stack size:
@EventBusSubscriber(modid = "mymod")
public class FishingAptitudeListener {
private static final ResourceLocation FISHING =
ResourceLocation.fromNamespaceAndPath("mymod", "fishing");
@SubscribeEvent(priority = EventPriority.LOWEST)
static void onItemFished(ItemFishedEvent event) {
if (!(event.getEntity() instanceof ServerPlayer sp)) return;
Set<ResourceLocation> rewarded = new HashSet<>();
for (ItemStack stack : event.getDrops()) {
if (stack.isEmpty()) continue;
ResourceLocation targetId =
BuiltInRegistries.ITEM.getKey(stack.getItem());
if (rewarded.add(targetId)) {
AptitudeSourceManager.grant(
sp, FISHING, targetId, BuiltInRegistries.ITEM);
}
}
}
}Replace mymod with your mod ID. FISHING matches the datapack's behavior ID, targetId identifies the caught item, and BuiltInRegistries.ITEM resolves item tags.
grant handles random ranges, player multipliers, first-time reward tracking, the growth curve, and the point cap. The listener only decides when to grant and which target to use.
grant API Reference
public static boolean grant(
ServerPlayer sp,
ResourceLocation behaviorId,
ResourceLocation targetId,
@Nullable Registry<?> registry
);| Parameter | Purpose |
|---|---|
sp | The player who triggered the behavior |
behaviorId | The datapack JSON's registry ID (namespace:relative_path), matching the file from Step 1 |
targetId | The concrete target ID for this event, such as the item caught, entity killed, or biome entered |
registry | The target's registry, used to resolve "#tag"; pass null if there is no corresponding registry |
Common registries:
- Entity types →
BuiltInRegistries.ENTITY_TYPE - Blocks →
BuiltInRegistries.BLOCK - Items →
BuiltInRegistries.ITEM - Biomes →
sp.server.registryAccess().registryOrThrow(Registries.BIOME) - Structures →
sp.server.registryAccess().registryOrThrow(Registries.STRUCTURE)
When registry is null, concrete IDs still match, but tags do not. Behaviors without a natural target can use a placeholder ID and configure their reward through default.
Return values:
true: aptitude was successfully granted, including gains below the next point's requirementfalse: nothing was granted, for example because no JSON exists, the target is excluded, the rolled reward becomes 0 after applying the multiplier, or the player has reached the total point cap
Querying Reward Ranges
Use AptitudeSourceManager.resolve(...) to display reward ranges. It does not roll random values, apply the multiplier, claim first-time rewards, or modify player data:
AptitudeSourceResolver.Resolution result =
AptitudeSourceManager.resolve(
sp, FISHING, targetId, BuiltInRegistries.ITEM);
if (result.applies()) {
long min = result.minReward();
long max = result.maxReward();
// Use min and max to display the available range before the player multiplier
}baseReward() and firstReward() query the regular reward and the currently available first-time reward separately. applies() indicates that the rules allow a positive reward; use AptitudeManager.canGainInsightPoints(sp) to check whether the player can still progress.
The old reward() method is deprecated and works only for fixed values. Use minReward() / maxReward() for random ranges.
Grant Flow
grant processes rewards in this order:
- Look up the behavior configuration, check
excludefirst, then use the first matchingspecialsentry ordefault. - Determine the regular reward range and any first-time reward this player has not claimed for this behavior and concrete target.
- Stop if the player has reached the total point cap. Otherwise, roll the two rewards separately, add them together, multiply by the player's
epiphany:aptitude_gain_multiplier, and round down. - If the result is positive, save the aptitude settlement and first-time reward claim together, then fire the level-up and value-change events.
Reaching the cap or receiving a total reward of 0 does not consume the first-time reward. If the regular reward is successfully granted, a first-time reward roll of 0 still counts as claimed. A large aptitude grant can earn multiple points; excess aptitude is discarded when the cap is reached.
First-time rewards are tracked by player, behavior ID, and concrete target ID, and persist across death and reconnecting. When matching a tag, distinct targets within it are tracked separately.
Sharing One Behavior Configuration Across Events
Different events, such as fishing, killing rare fish, and feeding fish, can call the same mymod:fishing behavior. Each listener supplies its own target ID, and the same JSON file's specials determine the reward.
Sharing a behavior ID also shares the first-time reward for the same player and target. For example, once a player claims a target's first-time reward through fishing, another listener using the same behavior and target IDs will grant only the regular reward.